from fastapi import APIRouter, HTTPException
from typing import List
from app.schemas.subject import SubjectCreate, SubjectResponse
from app.models.subject import Subject

router = APIRouter()

@router.get("/", response_model=List[SubjectResponse])
async def get_subjects():
    """获取所有学科"""
    return await Subject.all()

@router.post("/", response_model=SubjectResponse)
async def create_subject(subject: SubjectCreate):
    """创建学科"""
    return await Subject.create(**subject.dict()) 